//
//  YGOwnHelpBLL.m
//  yuanshangyiliao
//
//  Created by icholab on 2021/4/29.
//

#import "YGOwnHelpBLL.h"
#import "CNHTTPManager.h"
#import "YGFoodGuideTypeModel.h"
#import "YGSickListModel.h"
@implementation YGOwnHelpBLL

+(void)requestServerDetailWithModel:(OwnHelpRequestModel *)model
                           Success:(void (^)(NSString *pid))success
                               fail:(void (^)(NSError *error))fail{
    NSDictionary *dic = [model toDictionary];
    [[CNHTTPManager shared] POST:YG_SAVE_HELP_URL parameters:dic success:^(id responeObj) {
        NSString *str = [responeObj objectForKey:@"data"];

        if (success) {
            success(str);
        }
        } failure:^(NSError *error, NSString *errorDes) {
            if (fail) {
                fail(error);
            }
        }];
}

+(void)requestLaodongSuccess:(void (^)(NSArray <YGSickTypeModel *>* model))success
                          fail:(void (^)(NSError *error))fail{
    
    [[CNHTTPManager shared] GET:YG_LAODONG_QD_URL parameters:nil success:^(id responeObj) {
        NSArray *data = [responeObj objectForKey:@"data"];
        NSArray *models = [YGSickTypeModel arrayOfModelsFromDictionaries:data error:nil];
        if (success) {
            success(models);
        }
        } failure:^(NSError *error, NSString *errorDes) {
            if (fail) {
                fail(error);
            }
        }];
}


+(void)requestDiseaseSuccess:(void (^)(NSArray <YGFoodGuideTypeModel *>* model))success
                          fail:(void (^)(NSError *error))fail{
    
    [[CNHTTPManager shared] GET:YG_DISEASE_ONE_URL parameters:nil success:^(id responeObj) {
        NSArray *data = [responeObj objectForKey:@"data"];
        NSArray *models = [YGFoodGuideTypeModel arrayOfModelsFromDictionaries:data error:nil];
        if (success) {
            success(models);
        }
        } failure:^(NSError *error, NSString *errorDes) {
            if (fail) {
                fail(error);
            }
        }];
}

+(void)requestDiseaseID:(NSString *)pid Success:(void (^)(NSArray <YGSickListModel *>* model))success
                          fail:(void (^)(NSError *error))fail{
    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    [dic fa_setObjectSafe:pid forKey:@"pid"];
    
    [[CNHTTPManager shared] GET:YG_DISEASE_LOWER_URL parameters:dic success:^(id responeObj) {
        NSArray *data = [responeObj objectForKey:@"data"];
        NSArray *models = [YGSickListModel arrayOfModelsFromDictionaries:data error:nil];
        if (success) {
            success(models);
        }
        } failure:^(NSError *error, NSString *errorDes) {
            if (fail) {
                fail(error);
            }
        }];
}
@end


@implementation OwnHelpRequestModel


@end
